package com.loan.psychicloan.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.loan.psychicloan.R;
import com.loan.psychicloan.bean.HomeBean;
import com.loan.psychicloan.fragment.FragmentSample;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;


public class MainActivity extends FragmentActivity {

    public static boolean LOGIN ;
    public static FragmentSample fragmentSample;
    public static String PHONE_NUMBER;
    public static HomeBean.WeChat WeChact = new HomeBean.WeChat();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Logger.addLogAdapter(new AndroidLogAdapter());
        fragmentSample=new FragmentSample();
        getSupportFragmentManager().beginTransaction().replace(R.id.frame,fragmentSample).show(fragmentSample).commit();

        getspdata();


    }

    @Override
    protected void onResume() {
        super.onResume();
        //getspdata();
        Logger.t("mainactivity.onResume");

    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        getspdata();
        Logger.t("mainactivity.onNewIntent");
    }

    public void getspdata() {
        //使用SharePreferences取出保存的数据，并把数据显示在手机屏幕上
        //初始化数据
        SharedPreferences sharedPreferences = getSharedPreferences("config",0);
        //取出数据，如果取出的数据时空时，只需把getString("","")第二个参数设置成空字符串就行了，不用在判断
        PHONE_NUMBER = sharedPreferences.getString("PHONE_NUMBER","");
        LOGIN = sharedPreferences.getBoolean("LOGIN",false);
    }
}
